﻿@{
    NoteAndContent noteAndContent = ViewBag.noteAndContent;
    Note note = noteAndContent.note;
    User blogUser = ViewBag.blogUser;
    Repository repository = ViewBag.repository;
}
<!DOCTYPE html>
<html lang="zh-CN">
@await Html.PartialAsync("Header")
<body ondragstart="return false;" class="dark-theme">
    @await Html.PartialAsync("BodyTempLate")
    <div class="main-content" data-aos="fade-left" data-aos-duration="400">

        <div class="toolbar header bg-{{$.themeInfo.Color}}-{{$.themeInfo.ColorStrength}} color-white">
            <button class="icon-button" onclick="SideMenu.toggle(document.querySelector('#navigation-sidemenu'));"><i class="fa fa-bars"></i></button>
            <label class="toolbar-label">文章 - @note.Title</label>
            <span class="float-right" id="switch-container">
                <div class="switch">
                    <input type="checkbox" id="dark-theme-switch" onchange="Theme.setTheme(this.checked ? 'dark' : 'light')" />
                    <label for="dark-theme-switch"></label>
                    <label class="form-control-label">Dark</label>
                </div>
            </span>
        </div>

        <div id="postsContainer">
            <div id="posts">
                <div class="each-post">
                    <div class="title">
                        @note.Title
                    </div>
                    <div class="created-time">
                        @if (note != null && note.Tags != null && note.Tags.Length > 0)
                            @foreach (string tag in note.Tags)
                            {
                                <i class="fa fa-bookmark-o" style="color:#DA3E3E"></i>
                                @*@(tag);*@
                                <a href="/Blog/Tags_Posts/@repository.Id.ToHex()/@tag">@tag</a>

                                @Html.Raw("&nbsp; &nbsp;");
                            }
                        发布于 <span id="postmark">@note.PublicTime </span>
                        &nbsp;&nbsp;@(note.ReadNum)次围观&nbsp;&nbsp;@(note.CommentNum)条评论
                    </div>
                    <!-- 仅为移动端 -->
                    <div class="mobile-created-time">
                        @if (note != null && note.Tags != null && note.Tags.Length > 0)
                            @foreach (string tag in note.Tags)
                            {

                                <i class="fa fa-bookmark-o" style="color:#DA3E3E"></i>
                                @(tag);
                                @Html.Raw("&nbsp; &nbsp;");
                            }
                        发表于 <span id="postmark">@note.CreatedTime </span>
                        &nbsp;&nbsp;@(note.ReadNum)人围观&nbsp;&nbsp;@(note.CommentNum)条评论
                    </div>
                    <!--目录原来的位置-->
                    <!--移动到后面：目录-->
                    <!--<div id="blogNavContent" style="border-left:4px solid rgba(77,182,172,0.6)"></div>-->
                    <div id="blogNavContent" style="border-left:4px solid rgba(77,182,172,0.6)"></div>
                    <div class="desc" id="content">
                        @*{{if $.post.IsMarkdown }}
                            <div id="markdownContent" style="display: none">
                                <textarea>{{$.post.Content | raw}}</textarea>
                            </div>
                            <div style="padding: 20px; text-align: center">
                                <img src="{{$.themeBaseUrl}}/images/loading-32.gif" />
                            </div>
                            {{else}}
                            {{$.post.Content | raw}}
                            {{end}}*@
                        @if (note.IsMarkdown)
                        {
                            <div id="markdownContent" style="display: none">
                                <textarea>@Html.Raw(noteAndContent.noteContent.Content)</textarea>
                            </div>@Html.Raw(noteAndContent.noteContent.Content)
                            <div style="padding: 20px; text-align: center">
                                <img src="~/blog/images/loading-32.gif" />
                            </div>
                        }
                        else
                        {
                            @Html.Raw(noteAndContent.noteContent.Content)
                        }
                    </div>

                    @*<div class="pre-next-post" style="border-top:1px solid #f1f2f3;padding-top:10px;margin-top:20px;">
                            <p>上一篇: {{if $.prePost}}<a href="{{$.postUrl}}/{{$.prePost.UrlTitle}}">{{$.prePost.Title}}</a>{{else}}已经是第一篇啦{{end}}</p>
                            <p>下一篇: {{if $.nextPost}}<a href="{{$.postUrl}}/{{$.nextPost.UrlTitle}}">{{$.nextPost.Title}}</a>{{else}}已经是最后一篇啦{{end}}</p>
                        </div>*@
                    @await Html.PartialAsync("share_comment")
                </div>
            </div>
        </div>
    </div>

    @*{{template "footer_js.html" $}}
        {{template "highlight.html" $}}*@
    @await Html.PartialAsync("Footer_js")
    @await Html.PartialAsync("Highlight")
<script>
    //var siteUrl = "{{$.siteUrl}}"; // common.js需要
    var siteUrl = "@(ViewBag.siteUrl)"; // common.js需要
    // 以下 share_comment.js需要
    //var blogInfo={UserId: "{{$.blogInfo.UserId}}", OpenComment: {{$.blogInfo.OpenComment}}, CommentType: "{{$.blogInfo.CommentType}}"};
    //var noteId = "{{$.post.NoteId}}"; //
    //var preLikeNum = +"{{$.post.LikeNum}}";
    //var commentNum = +"{{$.post.CommentNum}}";

    var blogInfo = { UserId: "@blogUser.Id.ToHex()ToHex24()", OpenComment: true , CommentType: "default"};
    var noteId = "@note.Id.ToHex()"; //
    var preLikeNum = +"1122";
    var commentNum = +"0";
</script>
    <!-- 一些公用的js -->

    <script src="/blog/js/jsrender.js"></script>
    <script src="/blog/js/jquery-cookie-min.js"></script>
    <script src="/blog/js/bootstrap-dialog.min.js"></script>
    <script src="/blog/js/jquery.qrcode.min.js"></script>
    <script src="~/blog/themes/MaterialDesign/js/common.js"></script>
    <script src="~/blog/themes/MaterialDesign/js/share_comments.js"></script>
    <!-- markdown 调用markdown来解析得到html-->
    @if (note.IsMarkdown)
    {
        <script src="~/blog/libs/md2html/md2html.js"></script>
        <script>
            var content = $.trim($("#markdownContent textarea").val());
            md2Html(content, $("#content"), function (html) {
                $("pre").addClass("prettyprint linenums");
                prettyPrint();
            @*    initNav();
                weixin();*@
            });
        </script>
    }
    else
    {
        <script>
            $(function () {
                initNav();
                weixin();
            });
        </script>

    }
</body>
</html>